#pragma once
#include "pch.h"
#include "Direct3DApplication.h"

void Direct3DApplication::Initialize(CoreWindow^ window)
{
	coreWindow = window;
}

void Direct3DApplication::CreateDeviceAndSwapChain()
{
	UINT deviceCreationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
	//If debug add |= D3D11_CREATE_DEVICE_DEBUG;

	D3D_FEATURE_LEVEL* featureLevel = nullptr;
	ComPtr<ID3D11Device> tmpDevice;
	ComPtr<ID3D11DeviceContext> tmpContext;

	D3D11CreateDevice(
		nullptr,
		D3D_DRIVER_TYPE_HARDWARE,
		nullptr,
		deviceCreationFlags,
		nullptr,
		0,
		D3D11_SDK_VERSION,
		&tmpDevice,
		featureLevel,
		&tmpContext);

	tmpDevice.As(&d3dDevice);
	tmpContext.As(&d3dContext);
}

Direct3DApplication::Direct3DApplication()
{
	Initialize(CoreWindow::GetForCurrentThread());

	CreateDeviceAndSwapChain();
}